package org.monster.uiboot;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

/**
 * 添加活动
 */
public class AddAction extends ItemAction implements
        ActionListener {

    /**
     * 添加活动
     *
     * @param frame 片段
     */
    public AddAction(Frame frame) {
        super(frame);
    }

    /**
     * 活动执行
     *
     * @param e 活动事件
     */
    @Override
    public void actionPerformed(ActionEvent e) {
        jFileChooser.setCurrentDirectory(new File(System
                .getProperty("user.dir")));
        int selectedVal = jFileChooser.showOpenDialog(frame);
        if (selectedVal == JFileChooser.APPROVE_OPTION) {
            StringBuffer buffer = new StringBuffer();
            buffer.append("{dos-(1)-")
                    .append(jFileChooser.getSelectedFile().getPath())
                    .append("}");
            receiver.receive(buffer.toString());
        }

    }

}
